﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EMANIFEST.Dtos;

namespace TestSaveRecord
{
    [TestClass]
    public class TestDangerousGoodRecord
    {
        eManifestService.EmanifestServiceClient client = new eManifestService.EmanifestServiceClient();
        [TestMethod]
        public void TestDangerousGood()
        {
            try
            {
                DangerousGoodDto dangedto = new DangerousGoodDto();
                dangedto.DangerousGoodId = new Guid("FFAB207B-BBB4-49BA-A844-92EBFF278D52");
                dangedto.DocumentId = new Guid("DAB27624-2270-4C40-A977-8856C4A8388A");
                dangedto.CreaterId = new Guid("a6827a2d-2821-449d-9927-897e7ae5fb4e");
                dangedto.PortNameOfLoad = "C016";
                dangedto.PortNameOfUnload = "C016";
                dangedto.ContNumber = "VN56";
                dangedto.ContSealNumber = "VN045 update";
                dangedto.ItemStatus = 0;
                dangedto.CreatedDate = DateTime.Now;
                dangedto.IsTemp = true;


                ResponseDto res = client.SaveDangerousGoodRecord(dangedto);
                Console.WriteLine(res.IsSuccess);

                DangerousGoodDto dgdto = client.GetDangerousGoodById(dangedto.DangerousGoodId);
                if (dgdto != null)
                    Console.WriteLine("Cap nhat thanh cong");
                else
                    Console.WriteLine("Cap nhat that bai");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }



        }


        [TestMethod]
        public void DeleteDangerousGood()
        {
            try
            {
                ResponseDto res = client.DeleteDangerousGood(new Guid("FFAB207B-BBB4-49BA-A844-92EBFF278D52"));
               Console.WriteLine(res.IsSuccess);
               DangerousGoodDto dgDto = client.GetDangerousGoodById(new Guid("FFAB207B-BBB4-49BA-A844-92EBFF278D52"));
               if (dgDto == null)
                   Console.WriteLine("Delete thanh cong");
               else
                   Console.WriteLine("Delete that bai");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }


        [TestMethod]
        public void TestDangerousGoodItem()
        {
            try
            {
                DangerousGoodItemDto dangeItemdto = new DangerousGoodItemDto();
                Guid id = new Guid("FFAB207B-BBB4-49BA-A844-92EBFF278D52");

                dangeItemdto.DangerousGoodItemId = Guid.NewGuid();
                dangeItemdto.DangerousGoodId = id;
                dangeItemdto.RefNumber = "Nber 05";

                ResponseDto res = client.SaveDangerousGoodItemRecord(dangeItemdto);
                Console.WriteLine(res.IsSuccess);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }

        [TestMethod]
        public void DeleteDangerousGoodItem()
        {
            try
            {
                ResponseDto res = client.DeleteDangerousGoodItemById(new Guid("4FBE0CED-E70D-4ABE-8B2E-C4D10F00B9B9"));
                Console.WriteLine(res.IsSuccess + " , " + res.ErroeMessage);

            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }
    }
}
